home *** CD-ROM | disk | FTP | other *** search
-
- *******************************************************************
- * * * *
- * * DirBar by David Jenkins. * * * *
- * * * *
- * * * *
- *******************************************************************
-
- mvc macro
- lea \1,a0 source
- lea \2,a1 destination
- moveq #\3-1,d0 count
- move\@ move.b (a0)+,(a1)+ move byte
- dbra d0,move\@
- endm
-
- nolist
- include "exec/types.i"
- include "exec/memory.i"
- include "offsets/exec.ofs"
- include "offsets/dos.ofs"
- include "offsets/intuit.ofs"
- include "offsets/translat.ofs"
- include "offsets/layers.ofs"
-
- include "libraries/dos.i"
-
- include "devices/serial.i"
- include "devices/console.i"
- include "intuition/intuition.i"
-
- list
-
-
- * -------------------------------------------------------------- *
-
- sysbase equ 4
-
-
-
- startup move.l sp,saveSP Save the stack pointer, just in case
-
- * Open Layers library
-
- lea layersname,a1
- moveq #0,d0 ; load version number
- movea.l 4,a6 ; load exec library address
- jsr OpenLibrary(A6) ; call OpenLibrary
- tst.l d0 ok?
- bne layok yes
- rts
- layok move.l d0,layers save
-
-
-
- * Open intuition library
-
- lea IntuitionName(PC),A1
- moveq #0,d0 ; load version number
- movea.l 4,a6 ; load exec library address
- jsr OpenLibrary(A6) ; call OpenLibrary
- tst.l d0
- bne.s 1$
- move.l #24,ret return code
- bra layerbye
- 1$ move.l d0,intuit ; store intuition library pointer
-
- ********* open window
-
- lea window,a0
- movea.l intuit,A6
- jsr OpenWindow(A6) ; call OpenWindow
-
- tst.l D0
- bne.s windok
- move.l #10,ret return code
- bra closeint exit
-
- windok move.l d0,windowpoint
- move.l d0,a0
- moveq #0,d0
- moveq #0,d1
-
- ** Get layer information
-
- move.l wd_WLayer(a0),layer window layer
- movea.l wd_WScreen(a0),a1 screen pointer
- lea sc_LayerInfo(a1),a0 get Layer_info address
- move.l a0,layerinfo save
-
- ** Look for AmigaDOS window
-
- movea.l windowpoint,a0
- movea.l wd_WScreen(a0),a1 screen pointer
- move.l sc_FirstWindow(a1),wbwin get first window
- movea.l wbwin,a0 first window
- titlook movea.l wd_Title(a0),a1 title
- cmpa.l #0,a1
- beq.s nextwin no
- lea doswindow,a2 dos name
- moveq #7,d0 count
- 1$ cmpi.b #' ',(a1) blank?
- bne 2$ no
- adda.l #1,a1 next one
- bra.s 1$
- 2$ cmp.b (a2)+,(a1)+ right one?
- bne.s nextwin no
- dbra d0,1$
- move.l a0,wbwin save
- bra.s addgad
-
- nextwin movea.l wd_NextWindow(a0),a0 next one
- cmpa.l #0,a0
- beq notit not found
- bra.s titlook
-
- notit clr.l wbwin dos window not found
-
- addgad movea.l windowpoint,a0 window
-
- * get Window->UserPort->mp_SigBit into D0
-
- movea.l wd_UserPort(a0),a1 A1 = Window->UserPort
- moveq #0,d0
- move.b MP_SIGBIT(a1),d0 D0 = the Window's mp_SigBit
- moveq #1,d1
- lsl.l d0,d1 ; D1 = windowSigs
- or.l d1,waitflags update the waitFlags
- move.l d1,windowflag save
-
- * Find what task we are in, and install it in the msg ports
-
- sub.l a1,a1 my task
- move.l sysbase,a6 Exec Lib Ptr
- jsr FindTask(a6)
-
- move.l d0,d4 save task pointer
-
- **** get timer signal bit
-
- moveq #-1,d0
- jsr AllocSignal(a6) call AllocSignal
- move.l d0,d3 save signal bit
- bmi sigerr exit
-
- ** get port space
-
- portall moveq #MP_SIZE,d0 size of structure
- move.l #MEMF_CLEAR+MEMF_PUBLIC,d1 memory type = CLEAR and PUBLIC
- JSR AllocMem(a6) call AllocMem
-
- move.l d0,timerport save timer Port
- bne 1$
- move.l #16,ret return code
- bra openerr
-
- 1$ movea.l timerport,a1
- move.b d3,MP_SIGBIT(a1) set signal bit
- move.l d4,MP_SIGTASK(a1)
- move.l #timerportname,LN_NAME(a1) timer name
- move.b #NT_MESSAGE,LN_TYPE(a1) LN_TYPE = NT_MESSAGE(5)
- move.b #PA_SIGNAL,MP_FLAGS(a1)
- moveq #1,d1
- lsl.l d3,d1
- or.l d1,waitflags update the waitFlags
- move.l d1,timerflag timer wait flag
-
- ** add timer port
-
- move.l timerport,a1 Message Port
- jsr AddPort(a6) Add another Port to list
-
- lea timerreq,a1 timer IORequest
- move.b #NT_MESSAGE,LN_TYPE(a1) LN_TYPE = NT_MESSAGE(5)
- move.b #0,LN_PRI(a1) LN_PRI = 0
- move.l timerport,MN_REPLYPORT(a1) move in message port pointer
-
- ***** open vblank timer device *****
-
- lea TimerName(PC),a0 ; A0 = timer name
- * A1 = timeRequest
- moveq #1,d0 ; D0 = UNIT_VBLANK(1)
- moveq #0,d1
- jsr OpenDevice(A6) ; call OpenDevice
- tst.l d0
- bne openerr2
- move.w #TR_ADDREQUEST,IO_COMMAND+timerreq IO_COMMAND = TR_ADDREQUEST(9)
-
-
- ** set the timeRequest to wait for refresh time
-
- move.l #10,IO_SIZE+TV_SECS+timerreq TV_SECS = 120
- move.l #0,IO_SIZE+TV_MICRO+timerreq TV_MICRO= 0 ms
-
-
- ******** start the timer running
-
- lea timerreq,a1
- movea.l 4,a6 set Exec base
- jsr SendIO(A6) ; call SendIO
-
-
- *** set up gadgets
-
- ag
- lea gad0,a1 first gadget
- movea.l intuit,a6 intuition base
- ngad movea.l 0(a1),a3 next gadget
- movea.l windowpoint,a0 window
- move.l #0,d0 no requestors
- jsr AddGadget(a6) add gadget
- cmpa.l #0,a3 another one?
- beq.s nomoreg no
- movea.l a3,a1 next one
- bra ngad
-
- nomoreg jsr redogad
-
- waitloop move.l waitflags,D0 dD0 = waitFlags
- movea.l 4,a6 Exec base
- jsr Wait(A6) call Wait
-
- move.l d0,d3 save signal
- and.l timerflag,d0 is it timer?
- beq getmsg no must be from window
-
- timeget move.l timerport,a0 get message form timer port
- movea.l 4,a6 set Exec base
- jsr GetMsg(A6) call GetMsg
- tst.l d0 any more?
- beq.s waitloop no
-
- tst.b pop do popup?
- beq.s dopop yes
- bra retime
- dopop movea.l layers,a6 layers base
- movea.l layerinfo,a0 screen's layer info
- movea.l layer,a1 window's layer
-
- jsr UpfrontLayer(a6) pop
-
-
- ** set the timeRequest to wait for popup time
-
- retime move.l #10,IO_SIZE+TV_SECS+timerreq TV_SECS = 10
- move.l #0,IO_SIZE+TV_MICRO+timerreq TV_MICRO= 0 ms
-
-
- ******** start the timer running
-
- lea timerreq,A1
- movea.l 4,a6 set Exec base
- jsr SendIO(A6) ; call SendIO
-
- bra waitloop
-
- ** get msg
-
- getmsg movea.l 4,a6 set to Exec base
- move.l windowpoint,a1 window
- movea.l wd_UserPort(a1),A0 A0 = window's UserPort
- jsr GetMsg(A6) call GetMsg
- tst.l d0 D0 = message
- beq timeget no more messages so start Waiting
- movea.l d0,a1
- move.l im_Class(a1),class save class
- move.l im_IAddress(a1),a3 save gadget adderss
- jsr ReplyMsg(a6) call ReplyMessage
-
-
- intmsg cmpi.l #GADGETUP,class gadget selected?
- bne activetst no - see if act or deactivated
-
- *** Gadget selected. Branch to right routine
-
- moveq #0,d0
- move.w gg_GadgetID(a3),d0 get gadget number
- lsl.l #2,d0 *4
- lea routines,a0 list of routine addresses
- movea.l 0(a0,d0),a1 get routine
- jmp 0(a1) go and do it
-
- ** See if window was activated or deactivated
-
- activetst cmpi.l #ACTIVEWINDOW,class activated?
- beq.s redgad
-
- tryinact cmpi.l #INACTIVEWINDOW,class
- bne getmsg no
- redgad jsr redogad
- bra getmsg
-
-
- ** routines
-
- popup eori.b #3,gad8text reset colour
- eori.b #-1,pop set pop switch
- bra redos
-
- dir move.l #'dir ',commandsave
- move.b #3,gad0text first gadget text
- move.b #0,gad1text second gadget text
- redos jsr actdos
- jsr redogad reset gadgets
- bra getmsg
-
-
- lrout move.l #$4c495354,commandsave
- move.b #0,gad0text first gadget text
- move.b #3,gad1text second gadget text
- bra redos
-
- dir0 move.l #'df0:',disksave set up disk
- bra execdir execute it
-
- dir1 move.l #'df1:',disksave set up disk
- bra execdir execute it
-
- dirr move.l #'ram:',disksave set up disk
- bra execdir execute it
-
- dirv move.l #'vd0:',disksave set up disk
- bra execdir execute it
-
- info jsr actdos reactivate dos window
- jsr opendos open dos library
- lea infoc,a0 info command
- bra execinf
-
- execdir jsr actdos reactivate dos window
- jsr opendos open dos library
-
- move.l commandsave,command set up command
- mvc disksave,disk,4 move 4 bytes
- lea command,a0 dir command string
- execinf moveq #0,d2 input handle
- moveq #0,d3 output file handle
- move.l a0,d1
- move.l dosbase,a6
- jsr Execute(a6) Execute
-
- *** close dos library
-
- closedos move.l sysbase,a6 Exec base
- move.l dosbase,a1 Close the DOS library
- jsr CloseLibrary(a6)
- bra getmsg
-
- openerr2
- move.l #18,ret return code
- movea.l sysbase,a6
- moveq #0,d0 clear
- movea.l timerport,a0
- move.b MP_SIGBIT(a0),d0 get signal bit
- jsr FreeSignal(a6) free it
- bra closeint
-
- sigerr move.l #14,ret return code
- bra closewind
-
- quit
- move.l sysbase,a6
- lea timerreq,a1
- jsr AbortIO(a6) abort timer
-
- ** close timer device
-
- lea timerreq,a1 timer IORequest
- JSR CloseDevice(a6) ; call CloseDevice
-
- moveq #0,d0 clear
- movea.l timerport,a0
- move.b MP_SIGBIT(a0),d0 get signal bit
- jsr FreeSignal(a6) free it
-
- movea.l timerport,a1 Remove the timer Port
- jsr RemPort(a6)
-
- openerr
- movea.l timerport,a1 timer IORequest
- moveq #MP_SIZE,D0 size of structure
- jsr FreeMem(A6) call FreeMem
-
- closewind movea.l intuit,A6
- move.l windowpoint,a0 window
- jsr CloseWindow(A6) call CloseWindow
-
- closeint move.l sysbase,a6
- move.l intuit,a1
- jsr CloseLibrary(a6) close intuition
-
- layerbye move.l layers,a1 layers
- movea.l 4,a6 ; load exec library address
- jsr CloseLibrary(A6) call CloseLibrary
-
- move.l ret,d1 Return Code
- move.l d1,d0
-
- rts
-
- *** Refresh gadgets
-
- redogad movea.l windowpoint,a0 window
- movea.l wd_RPort(a0),a0 window's RPort
- lea clear,a1 title
- moveq #0,d0
- moveq #0,d1
- movea.l intuit,A6
- jsr PrintIText(A6) call PrintIText
-
- lea gad8,a0 first gadget
- movea.l windowpoint,a1 window
- movea.l #0,a2 no requestors
- jsr RefreshGadgets(a6) redo gadgets
- rts
-
- *** Reactivate dos window
-
- actdos tst.l wbwin did we find the dos window?
- beq.s nodos no
- movea.l intuit,a6
- movea.l wbwin,a0 dos window
- jsr ActivateWindow(a6) activate it
- nodos jsr redogad refresh gadgets
- rts
-
- * Open Dos library
-
- opendos move.l sysbase,a6 Pointer to Exec Library
- lea thedos(pc),a1 Point to title of DOS
- moveq #0,d0 Version number
- jsr OpenLibrary(a6)
- move.l d0,dosbase DOS library Pointer
- rts
-
- *** Long words
-
- routines dc.l dir,lrout,dir0,dir1,dirr,dirv,info,quit,popup
- cnop 0,2
- commandsave dc.b 'dir '
-
- ****************** window structure **********************
-
-
-
- window dc.w 2 left edge
- dc.w 1 top edge
- wwidth dc.w 178 width
- wheight dc.w 8 Height
- dc.b 0 detail pen
- dc.b 1 block pen
- dc.l GADGETUP+ACTIVEWINDOW+INACTIVEWINDOW IDCMPflags
- dc.l BORDERLESS+NOCAREREFRESH+WINDOWDRAG flags
- dc.l 0 first gadget
- dc.l 0 check mark
- dc.l 0 title
- dc.l 0 screen
- dc.l 0 bit map
- dc.w 0 minimum width
- dc.w 0 minimum height
- wmax dc.w 0 max width
- hmax dc.w 0 max height
- dc.w 1 workbench
-
- ************ Gadgets **********
- gwidth equ 18
- le equ 4
-
- gad0 dc.l gad1 next gadget
- dc.w le left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad0text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 0 GadgetID
- dc.l 0 UserData
-
-
- gad1 dc.l gad2 next gadget
- dc.w le+gwidth*1 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad1text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 1 GadgetID
- dc.l 0 UserData
-
-
- gad2 dc.l gad3 next gadget
- dc.w le+gwidth*2 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad2text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 2 GadgetID
- dc.l 0 UserData
-
- gad3 dc.l gad4 next gadget
- dc.w le+gwidth*3 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad3text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 3 GadgetID
- dc.l 0 UserData
-
-
- gad4 dc.l gad5 next gadget
- dc.w le+gwidth*4 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad4text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 4 GadgetID
- dc.l 0 UserData
-
-
- gad5 dc.l gad6 next gadget
- dc.w le+gwidth*5 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad5text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 5 GadgetID
- dc.l 0 UserData
-
-
- gad6 dc.l gad7 next gadget
- dc.w le+gwidth*6 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad6text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 6 GadgetID
- dc.l 0 UserData
-
-
- gad7 dc.l gad8 next gadget
- dc.w le+gwidth*7 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad7text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 7 GadgetID
- dc.l 0 UserData
-
-
- gad8 dc.l 0 next gadget
- dc.w le+gwidth*8 left edge
- dc.w 0 top edge
- dc.w gwidth width
- dc.w 8 height
- dc.w GADGHCOMP flags
- dc.w RELVERIFY activation flags
- dc.w BOOLGADGET type
- dc.l 0 border structure
- dc.l 0 SelectRender
- dc.l gad8text GadgetText
- dc.l 0 MutualExclude
- dc.l 0 SpecialInfo
- dc.w 8 GadgetID
- dc.l 0 UserData
-
- cnop 0,2
- gad0text dc.b 3,1,1,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g0text,0
-
- cnop 0,2
- g0text dc.b 'D',0
-
- cnop 0,2
- gad1text dc.b 0,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g1text,0
-
- cnop 0,2
- g1text dc.b 'L',0
-
- cnop 0,2
- gad2text dc.b 0,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g2text,0
-
- cnop 0,2
- g2text dc.b '0',0
-
- cnop 0,2
- gad3text dc.b 0,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g3text,0
-
- cnop 0,2
- g3text dc.b '1',0
-
- cnop 0,2
- gad4text dc.b 0,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g4text,0
-
- cnop 0,2
- g4text dc.b 'R',0
-
- cnop 0,2
- gad5text dc.b 0,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g5text,0
-
- cnop 0,2
- g5text dc.b 'V',0
-
- cnop 0,2
- gad6text dc.b 0,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g6text,0
-
- cnop 0,2
- g6text dc.b 'I',0
-
- cnop 0,2
- gad7text dc.b 0,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g7text,0
-
- cnop 0,2
- g7text dc.b 'E',0
-
- cnop 0,2
- gad8text dc.b 3,1,0,0
- dc.w (gwidth-10)/2,1
- dc.l 0,g8text,0
-
- cnop 0,2
- g8text dc.b 'P',0
-
- cnop 0,2
- clear dc.b 0,1,1,0
- dc.w 0,0
- dc.l 0,title,0
-
- cnop 0,2
- layersname dc.b 'layers.library',0
- cnop 0,2
- IntuitionName dc.b 'intuition.library',0
- cnop 0,2
- thedos DOSNAME
-
- cnop 0,2
- doswindow dc.b 'AmigaDOS',0
-
- cnop 0,2
- title dc.b ' ',0
- cnop 0,2
- command dc.b 'dir '
- disk dc.b 'df0:',0
- cnop 0,2
- infoc dc.b 'info',0
- cnop 0,2
- TimerName DC.B 'timer.device',0
-
- cnop 0,2
- timerportname DC.B 'dirbartimer',0
-
- section vars,bss
-
- startbss
-
- cnop 0,4
-
-
- * Long Words
-
- layer ds.l 1
- layers ds.l 1
- layerinfo ds.l 1
-
- saveSP ds.l 1 Initial Stack Pointer
- dosbase ds.l 1 Base of Dos library
- intuit ds.l 1 intuition library pointer
- windowpoint ds.l 1 pointer to window
- waitflags ds.l 1 flags to wait for
- wbwin ds.l 1 pointer to dos window
- class ds.l 1 class
- disksave ds.l 1 disk name
- timerflag ds.l 1 timer wait bit
- timerport ds.l 1 timer MsgPort pointer
- cnop 0,4
- timerreq ds.b IOTV_SIZE timer IOReq
- windowflag ds.l 1 window wait bit
- ret ds.l 1 return code
-
- * Words
-
- * Bytes
-
- pop ds.b 1 popup switch
-
- endbss
-
-
- end
-
-